import time

from selenium import webdriver
from selenium.webdriver.common.by import By
# 初始化driver
driver = webdriver.Chrome()
# 打开指定网页
driver.get("https://www.baidu.com/")

# 设置隐式等待
driver.implicitly_wait(15)
# 输入内容
driver.find_element(By.ID,"kw").send_keys("selenium")
# 点击搜索按钮
driver.find_element(By.ID,"su").click()
time.sleep(2)
# 操作滚动条
win1 = "window.scrollBy(0,500)" # Y轴向下500像素
win2 = "window.scrollBy(0,-500)" # Y轴向上500像素
win3 = "window.scrollBy(500,0)" # x轴向右500像素
win4 = "window.scrollBy(-500,0)" # x轴向左500像素
# 执行这个js
driver.execute_script(win1)
time.sleep(2)
driver.execute_script(win2)
time.sleep(2)
driver.execute_script(win3)
time.sleep(2)
driver.execute_script(win4)
time.sleep(7)



